home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / tree / FixedHeightLayoutCache$FHTreeStateNode.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  8.3 KB  |  538 lines

  1. package javax.swing.tree;
  2.  
  3. class FixedHeightLayoutCache$FHTreeStateNode extends DefaultMutableTreeNode {
  4.    // $FF: synthetic field
  5.    private final FixedHeightLayoutCache this$0;
  6.    protected boolean isExpanded;
  7.    protected int childIndex;
  8.    protected int row;
  9.    protected TreePath path;
  10.  
  11.    public FixedHeightLayoutCache$FHTreeStateNode(FixedHeightLayoutCache var1, Object var2, int var3, int var4) {
  12.       super(var2);
  13.       this.this$0 = var1;
  14.       this.childIndex = var3;
  15.       this.row = var4;
  16.    }
  17.  
  18.    protected void addNode(FixedHeightLayoutCache$FHTreeStateNode var1) {
  19.       boolean var2 = false;
  20.       int var3 = var1.getChildIndex();
  21.       int var4 = 0;
  22.  
  23.       for(int var5 = ((DefaultMutableTreeNode)this).getChildCount(); var4 < var5; ++var4) {
  24.          if (((FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var4)).getChildIndex() > var3) {
  25.             var2 = true;
  26.             ((DefaultMutableTreeNode)this).insert(var1, var4);
  27.             var4 = var5;
  28.          }
  29.       }
  30.  
  31.       if (!var2) {
  32.          ((DefaultMutableTreeNode)this).add(var1);
  33.       }
  34.  
  35.    }
  36.  
  37.    protected void adjustChildIndexs(int var1, int var2) {
  38.       int var3 = var1;
  39.  
  40.       for(int var4 = ((DefaultMutableTreeNode)this).getChildCount(); var3 < var4; ++var3) {
  41.          FixedHeightLayoutCache$FHTreeStateNode var10000 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var3);
  42.          var10000.childIndex += var2;
  43.       }
  44.  
  45.    }
  46.  
  47.    protected void adjustRowBy(int var1) {
  48.       this.row += var1;
  49.       if (this.isExpanded) {
  50.          for(int var2 = ((DefaultMutableTreeNode)this).getChildCount() - 1; var2 >= 0; --var2) {
  51.             ((FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var2)).adjustRowBy(var1);
  52.          }
  53.       }
  54.  
  55.    }
  56.  
  57.    protected void adjustRowBy(int var1, int var2) {
  58.       if (this.isExpanded) {
  59.          for(int var3 = ((DefaultMutableTreeNode)this).getChildCount() - 1; var3 >= var2; --var3) {
  60.             ((FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var3)).adjustRowBy(var1);
  61.          }
  62.       }
  63.  
  64.       FixedHeightLayoutCache$FHTreeStateNode var4 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getParent();
  65.       if (var4 != null) {
  66.          var4.adjustRowBy(var1, ((DefaultMutableTreeNode)var4).getIndex(this) + 1);
  67.       }
  68.  
  69.    }
  70.  
  71.    protected void childInsertedAtModelIndex(int var1, boolean var2) {
  72.       int var4 = ((DefaultMutableTreeNode)this).getChildCount();
  73.  
  74.       for(int var5 = 0; var5 < var4; ++var5) {
  75.          FixedHeightLayoutCache$FHTreeStateNode var3 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var5);
  76.          if (var3.childIndex >= var1) {
  77.             if (var2) {
  78.                this.adjustRowBy(1, var5);
  79.                FixedHeightLayoutCache.access$3(this.this$0, 1);
  80.             }
  81.  
  82.             while(var5 < var4) {
  83.                ++((FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var5)).childIndex;
  84.                ++var5;
  85.             }
  86.  
  87.             return;
  88.          }
  89.       }
  90.  
  91.       if (var2) {
  92.          this.adjustRowBy(1, var4);
  93.          FixedHeightLayoutCache.access$3(this.this$0, 1);
  94.       }
  95.  
  96.    }
  97.  
  98.    protected void collapse(boolean var1) {
  99.       if (this.isExpanded) {
  100.          TreePath[] var2;
  101.          if (this.this$0.treeSelectionModel != null) {
  102.             var2 = this.this$0.treeSelectionModel.getSelectionPaths();
  103.          } else {
  104.             var2 = null;
  105.          }
  106.  
  107.          if (this.isVisible() && var1) {
  108.             int var3 = this.getTotalChildCount();
  109.             this.isExpanded = false;
  110.             FixedHeightLayoutCache.access$3(this.this$0, -var3);
  111.             this.adjustRowBy(-var3, 0);
  112.          } else {
  113.             this.isExpanded = false;
  114.          }
  115.  
  116.          if (var2 != null) {
  117.             boolean var6 = false;
  118.             TreePath var4 = this.getTreePath();
  119.  
  120.             for(int var5 = var2.length - 1; var5 >= 0; --var5) {
  121.                if (var2[var5] != null && var4.isDescendant(var2[var5]) && !var4.equals(var2[var5])) {
  122.                   var6 = true;
  123.                } else {
  124.                   var2[var5] = null;
  125.                }
  126.             }
  127.  
  128.             if (var6) {
  129.                this.this$0.treeSelectionModel.removeSelectionPaths(var2);
  130.             }
  131.          }
  132.  
  133.          if (var1 && this.isVisible() && this.this$0.treeSelectionModel != null) {
  134.             this.this$0.treeSelectionModel.resetRowSelection();
  135.          }
  136.       }
  137.  
  138.    }
  139.  
  140.    protected FixedHeightLayoutCache$FHTreeStateNode createChildFor(Object var1) {
  141.       int var2 = this.this$0.treeModel.getIndexOfChild(((DefaultMutableTreeNode)this).getUserObject(), var1);
  142.       if (var2 < 0) {
  143.          return null;
  144.       } else {
  145.          FixedHeightLayoutCache$FHTreeStateNode var4 = FixedHeightLayoutCache.access$2(this.this$0, var1, var2);
  146.          int var5;
  147.          if (this.isVisible()) {
  148.             var5 = this.getRowToModelIndex(var2);
  149.          } else {
  150.             var5 = -1;
  151.          }
  152.  
  153.          var4.row = var5;
  154.          int var6 = 0;
  155.  
  156.          for(int var7 = ((DefaultMutableTreeNode)this).getChildCount(); var6 < var7; ++var6) {
  157.             FixedHeightLayoutCache$FHTreeStateNode var3 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var6);
  158.             if (var3.childIndex > var2) {
  159.                ((DefaultMutableTreeNode)this).insert(var4, var6);
  160.                return var4;
  161.             }
  162.          }
  163.  
  164.          ((DefaultMutableTreeNode)this).add(var4);
  165.          return var4;
  166.       }
  167.    }
  168.  
  169.    protected void didAdjustTree() {
  170.    }
  171.  
  172.    protected void didExpand() {
  173.       int var1 = this.setRowAndChildren(this.row);
  174.       FixedHeightLayoutCache$FHTreeStateNode var2 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getParent();
  175.       int var3 = var1 - this.row - 1;
  176.       if (var2 != null) {
  177.          var2.adjustRowBy(var3, ((DefaultMutableTreeNode)var2).getIndex(this) + 1);
  178.       }
  179.  
  180.       FixedHeightLayoutCache.access$3(this.this$0, var3);
  181.    }
  182.  
  183.    protected void expand() {
  184.       if (!this.isExpanded) {
  185.          boolean var1 = this.isVisible();
  186.          this.isExpanded = true;
  187.          if (var1) {
  188.             this.didExpand();
  189.          }
  190.  
  191.          if (var1 && this.this$0.treeSelectionModel != null) {
  192.             this.this$0.treeSelectionModel.resetRowSelection();
  193.          }
  194.       }
  195.  
  196.    }
  197.  
  198.    protected void expandParentAndReceiver() {
  199.       FixedHeightLayoutCache$FHTreeStateNode var1 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getParent();
  200.       if (var1 != null) {
  201.          var1.expandParentAndReceiver();
  202.       }
  203.  
  204.       this.expand();
  205.    }
  206.  
  207.    public FixedHeightLayoutCache$FHTreeStateNode getChildAtModelIndex(int var1) {
  208.       for(int var2 = ((DefaultMutableTreeNode)this).getChildCount() - 1; var2 >= 0; --var2) {
  209.          if (((FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var2)).childIndex == var1) {
  210.             return (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var2);
  211.          }
  212.       }
  213.  
  214.       return null;
  215.    }
  216.  
  217.    public int getChildIndex() {
  218.       return this.childIndex;
  219.    }
  220.  
  221.    protected int getCountTo(int var1) {
  222.       int var3 = var1 + 1;
  223.       int var4 = 0;
  224.  
  225.       for(int var5 = ((DefaultMutableTreeNode)this).getChildCount(); var4 < var5; ++var4) {
  226.          FixedHeightLayoutCache$FHTreeStateNode var2 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var4);
  227.          if (var2.childIndex >= var1) {
  228.             var4 = var5;
  229.          } else {
  230.             var3 += var2.getTotalChildCount();
  231.          }
  232.       }
  233.  
  234.       if (super.parent != null) {
  235.          return var3 + ((FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getParent()).getCountTo(this.childIndex);
  236.       } else if (!this.this$0.isRootVisible()) {
  237.          return var3 - 1;
  238.       } else {
  239.          return var3;
  240.       }
  241.    }
  242.  
  243.    protected int getNumExpandedChildrenTo(int var1) {
  244.       int var3 = var1;
  245.       int var4 = 0;
  246.  
  247.       for(int var5 = ((DefaultMutableTreeNode)this).getChildCount(); var4 < var5; ++var4) {
  248.          FixedHeightLayoutCache$FHTreeStateNode var2 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var4);
  249.          if (var2.childIndex >= var1) {
  250.             return var3;
  251.          }
  252.  
  253.          var3 += var2.getTotalChildCount();
  254.       }
  255.  
  256.       return var3;
  257.    }
  258.  
  259.    protected boolean getPathForRow(int var1, int var2, FixedHeightLayoutCache.SearchInfo var3) {
  260.       if (this.row == var1) {
  261.          var3.node = this;
  262.          var3.isNodeParentNode = false;
  263.          var3.childIndex = this.childIndex;
  264.          return true;
  265.       } else {
  266.          FixedHeightLayoutCache$FHTreeStateNode var5 = null;
  267.          int var6 = 0;
  268.  
  269.          for(int var7 = ((DefaultMutableTreeNode)this).getChildCount(); var6 < var7; ++var6) {
  270.             FixedHeightLayoutCache$FHTreeStateNode var4 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var6);
  271.             if (var4.row > var1) {
  272.                if (var6 == 0) {
  273.                   var3.node = this;
  274.                   var3.isNodeParentNode = true;
  275.                   var3.childIndex = var1 - this.row - 1;
  276.                   return true;
  277.                }
  278.  
  279.                int var8 = 1 + var4.row - (var4.childIndex - var5.childIndex);
  280.                if (var1 < var8) {
  281.                   return var5.getPathForRow(var1, var8, var3);
  282.                }
  283.  
  284.                var3.node = this;
  285.                var3.isNodeParentNode = true;
  286.                var3.childIndex = var1 - var8 + var5.childIndex + 1;
  287.                return true;
  288.             }
  289.  
  290.             var5 = var4;
  291.          }
  292.  
  293.          int var10 = this.this$0.treeModel.getChildCount(((DefaultMutableTreeNode)this).getUserObject());
  294.          if (var5 != null) {
  295.             int var11 = var2 - (var10 - var5.childIndex) + 1;
  296.             if (var1 < var11) {
  297.                return var5.getPathForRow(var1, var11, var3);
  298.             } else {
  299.                var3.node = this;
  300.                var3.isNodeParentNode = true;
  301.                var3.childIndex = var1 - var11 + var5.childIndex + 1;
  302.                return true;
  303.             }
  304.          } else {
  305.             int var9 = var1 - this.row - 1;
  306.             if (var9 >= var10) {
  307.                return false;
  308.             } else {
  309.                var3.node = this;
  310.                var3.isNodeParentNode = true;
  311.                var3.childIndex = var9;
  312.                return true;
  313.             }
  314.          }
  315.       }
  316.    }
  317.  
  318.    public int getRow() {
  319.       return this.row;
  320.    }
  321.  
  322.    public int getRowToModelIndex(int var1) {
  323.       int var3 = this.getRow() + 1;
  324.       int var5 = 0;
  325.  
  326.       for(int var6 = ((DefaultMutableTreeNode)this).getChildCount(); var5 < var6; ++var5) {
  327.          FixedHeightLayoutCache$FHTreeStateNode var2 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var5);
  328.          if (var2.childIndex >= var1) {
  329.             if (var2.childIndex == var1) {
  330.                return var2.row;
  331.             }
  332.  
  333.             if (var5 == 0) {
  334.                return this.getRow() + 1 + var1;
  335.             }
  336.  
  337.             return var2.row - (var2.childIndex - var1);
  338.          }
  339.       }
  340.  
  341.       return this.getRow() + 1 + this.getTotalChildCount() - (this.this$0.treeModel.getChildCount(((DefaultMutableTreeNode)this).getUserObject()) - var1);
  342.    }
  343.  
  344.    public int getTotalChildCount() {
  345.       if (!this.isExpanded()) {
  346.          return 0;
  347.       } else {
  348.          FixedHeightLayoutCache$FHTreeStateNode var1 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getParent();
  349.          int var2;
  350.          if (var1 != null && (var2 = ((DefaultMutableTreeNode)var1).getIndex(this)) + 1 < ((DefaultMutableTreeNode)var1).getChildCount()) {
  351.             FixedHeightLayoutCache$FHTreeStateNode var5 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)var1).getChildAt(var2 + 1);
  352.             return var5.row - this.row - (var5.childIndex - this.childIndex);
  353.          } else {
  354.             int var3 = this.this$0.getModel().getChildCount(((DefaultMutableTreeNode)this).getUserObject());
  355.  
  356.             for(int var4 = ((DefaultMutableTreeNode)this).getChildCount() - 1; var4 >= 0; --var4) {
  357.                var3 += ((FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var4)).getTotalChildCount();
  358.             }
  359.  
  360.             return var3;
  361.          }
  362.       }
  363.    }
  364.  
  365.    public TreePath getTreePath() {
  366.       return this.path;
  367.    }
  368.  
  369.    public int getVisibleLevel() {
  370.       return this.this$0.isRootVisible() ? ((DefaultMutableTreeNode)this).getLevel() : ((DefaultMutableTreeNode)this).getLevel() - 1;
  371.    }
  372.  
  373.    public boolean isExpanded() {
  374.       return this.isExpanded;
  375.    }
  376.  
  377.    public boolean isVisible() {
  378.       FixedHeightLayoutCache$FHTreeStateNode var1 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getParent();
  379.       if (var1 == null) {
  380.          return true;
  381.       } else {
  382.          return var1.isExpanded() && var1.isVisible();
  383.       }
  384.    }
  385.  
  386.    protected void makeVisible() {
  387.       FixedHeightLayoutCache$FHTreeStateNode var1 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getParent();
  388.       if (var1 != null) {
  389.          var1.expandParentAndReceiver();
  390.       }
  391.  
  392.    }
  393.  
  394.    public void remove(int var1) {
  395.       FixedHeightLayoutCache$FHTreeStateNode var2 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var1);
  396.       var2.removeFromMapping();
  397.       super.remove(var1);
  398.    }
  399.  
  400.    protected void removeChildAtModelIndex(int var1, boolean var2) {
  401.       FixedHeightLayoutCache$FHTreeStateNode var3 = this.getChildAtModelIndex(var1);
  402.       if (var3 != null) {
  403.          int var4 = var3.getRow();
  404.          int var5 = ((DefaultMutableTreeNode)this).getIndex(var3);
  405.          var3.collapse(false);
  406.          this.remove(var5);
  407.          this.adjustChildIndexs(var5, -1);
  408.          if (var2) {
  409.             this.resetChildrenRowsFrom(var4, var5, var1);
  410.          }
  411.       } else {
  412.          int var7 = ((DefaultMutableTreeNode)this).getChildCount();
  413.  
  414.          for(int var6 = 0; var6 < var7; ++var6) {
  415.             FixedHeightLayoutCache$FHTreeStateNode var8 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var6);
  416.             if (var8.childIndex >= var1) {
  417.                if (var2) {
  418.                   this.adjustRowBy(-1, var6);
  419.                   FixedHeightLayoutCache.access$3(this.this$0, -1);
  420.                }
  421.  
  422.                while(var6 < var7) {
  423.                   --((FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var6)).childIndex;
  424.                   ++var6;
  425.                }
  426.  
  427.                return;
  428.             }
  429.          }
  430.  
  431.          if (var2) {
  432.             this.adjustRowBy(-1, var7);
  433.             FixedHeightLayoutCache.access$3(this.this$0, -1);
  434.          }
  435.       }
  436.  
  437.    }
  438.  
  439.    protected void removeFromMapping() {
  440.       if (this.path != null) {
  441.          FixedHeightLayoutCache.access$1(this.this$0, this);
  442.  
  443.          for(int var1 = ((DefaultMutableTreeNode)this).getChildCount() - 1; var1 >= 0; --var1) {
  444.             ((FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var1)).removeFromMapping();
  445.          }
  446.       }
  447.  
  448.    }
  449.  
  450.    protected void resetChildrenPaths(TreePath var1) {
  451.       FixedHeightLayoutCache.access$1(this.this$0, this);
  452.       if (var1 == null) {
  453.          this.path = new TreePath(((DefaultMutableTreeNode)this).getUserObject());
  454.       } else {
  455.          this.path = var1.pathByAddingChild(((DefaultMutableTreeNode)this).getUserObject());
  456.       }
  457.  
  458.       FixedHeightLayoutCache.access$0(this.this$0, this);
  459.  
  460.       for(int var2 = ((DefaultMutableTreeNode)this).getChildCount() - 1; var2 >= 0; --var2) {
  461.          ((FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var2)).resetChildrenPaths(this.path);
  462.       }
  463.  
  464.    }
  465.  
  466.    protected void resetChildrenRowsFrom(int var1, int var2, int var3) {
  467.       int var9 = var1;
  468.       int var5 = var3;
  469.       int var7 = ((DefaultMutableTreeNode)this).getChildCount();
  470.  
  471.       for(int var8 = var2; var8 < var7; ++var8) {
  472.          FixedHeightLayoutCache$FHTreeStateNode var6 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var8);
  473.          var9 += var6.childIndex - var5;
  474.          var5 = var6.childIndex + 1;
  475.          if (var6.isExpanded) {
  476.             var9 = var6.setRowAndChildren(var9);
  477.          } else {
  478.             var6.row = var9++;
  479.          }
  480.       }
  481.  
  482.       var9 += this.this$0.treeModel.getChildCount(((DefaultMutableTreeNode)this).getUserObject()) - var5;
  483.       FixedHeightLayoutCache$FHTreeStateNode var11 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getParent();
  484.       if (var11 != null) {
  485.          var11.resetChildrenRowsFrom(var9, ((DefaultMutableTreeNode)var11).getIndex(this) + 1, this.childIndex + 1);
  486.       } else {
  487.          FixedHeightLayoutCache.access$5(this.this$0, var9);
  488.       }
  489.  
  490.    }
  491.  
  492.    public void setParent(MutableTreeNode var1) {
  493.       super.setParent(var1);
  494.       if (var1 != null) {
  495.          this.path = ((FixedHeightLayoutCache$FHTreeStateNode)var1).getTreePath().pathByAddingChild(((DefaultMutableTreeNode)this).getUserObject());
  496.          FixedHeightLayoutCache.access$0(this.this$0, this);
  497.       }
  498.  
  499.    }
  500.  
  501.    protected int setRowAndChildren(int var1) {
  502.       this.row = var1;
  503.       if (!this.isExpanded()) {
  504.          return this.row + 1;
  505.       } else {
  506.          int var7 = this.row + 1;
  507.          int var3 = 0;
  508.          int var5 = ((DefaultMutableTreeNode)this).getChildCount();
  509.  
  510.          for(int var6 = 0; var6 < var5; ++var6) {
  511.             FixedHeightLayoutCache$FHTreeStateNode var4 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getChildAt(var6);
  512.             var7 += var4.childIndex - var3;
  513.             var3 = var4.childIndex + 1;
  514.             if (var4.isExpanded) {
  515.                var7 = var4.setRowAndChildren(var7);
  516.             } else {
  517.                var4.row = var7++;
  518.             }
  519.          }
  520.  
  521.          return var7 + this.this$0.treeModel.getChildCount(((DefaultMutableTreeNode)this).getUserObject()) - var3;
  522.       }
  523.    }
  524.  
  525.    public void setUserObject(Object var1) {
  526.       super.setUserObject(var1);
  527.       if (this.path != null) {
  528.          FixedHeightLayoutCache$FHTreeStateNode var2 = (FixedHeightLayoutCache$FHTreeStateNode)((DefaultMutableTreeNode)this).getParent();
  529.          if (var2 != null) {
  530.             this.resetChildrenPaths(var2.getTreePath());
  531.          } else {
  532.             this.resetChildrenPaths((TreePath)null);
  533.          }
  534.       }
  535.  
  536.    }
  537. }
  538.